package com.aspose.cells;

class zcb {
   private byte a = 5;
   private zux b;
   private zcv c;
   private int d;
   private int e;
   private int f;

   zcb(byte[] var1, int var2) throws Exception {
      this.a(var1, var2, var2);
   }

   zcb() {
      this.f = 96;
      this.b = new zux();
      this.c = new zcv(this);
   }

   public ImageFormat a() throws Exception {
      if (this.f() != null && this.f().e() != null) {
         switch(this.n()) {
         case -4:
         case -2:
            return ImageFormat.getBmp();
         case -3:
            return ImageFormat.getGif();
         case -1:
         case 0:
         case 1:
         case 32:
            return a(this.f().e());
         case 2:
            return ImageFormat.getEmf();
         case 3:
            return ImageFormat.getWmf();
         case 4:
            return ImageFormat.getEmf();
         case 5:
            return ImageFormat.getJpeg();
         case 6:
            return ImageFormat.getPng();
         case 7:
            return ImageFormat.getBmp();
         case 8:
         case 9:
         case 10:
         case 11:
         case 12:
         case 13:
         case 14:
         case 15:
         case 16:
         case 17:
         case 18:
         case 19:
         case 20:
         case 21:
         case 22:
         case 23:
         case 24:
         case 25:
         case 26:
         case 27:
         case 28:
         case 29:
         case 30:
         case 31:
         default:
            return ImageFormat.getBmp();
         }
      } else {
         return ImageFormat.getBmp();
      }
   }

   byte[] b() {
      if (this.f().e() == null) {
         return null;
      } else {
         switch(this.n()) {
         case -4:
         case -2:
            return this.f().e();
         case -3:
            return this.f().e();
         case -1:
         case 0:
         case 1:
         case 32:
            return this.f().e();
         case 2:
            return zcgc.a(false, false, this.k(), this.l(), this.m(), this.f().e(), this.f().a);
         case 3:
            return zcgc.a(true, false, this.k(), this.l(), this.m(), this.f().e(), this.f().a);
         case 4:
            return zcgc.a(false, true, this.k(), this.l(), this.m(), this.f().e(), this.f().a);
         case 5:
            return this.f().e();
         case 6:
            return this.f().e();
         case 7:
            return b(this.f().e());
         case 8:
         case 9:
         case 10:
         case 11:
         case 12:
         case 13:
         case 14:
         case 15:
         case 16:
         case 17:
         case 18:
         case 19:
         case 20:
         case 21:
         case 22:
         case 23:
         case 24:
         case 25:
         case 26:
         case 27:
         case 28:
         case 29:
         case 30:
         case 31:
         default:
            return null;
         }
      }
   }

   void a(byte[] var1, int var2, int var3) throws Exception {
      int var4 = var1.length;
      com.aspose.cells.b.a.d.zh var5 = new com.aspose.cells.b.a.d.zh(var1);
      int[] var6 = a((com.aspose.cells.b.a.d.zm)var5, var2, var3);
      byte var7 = (byte)var6[0];
      int var8 = var6[1];
      int var9 = var6[2];
      com.aspose.cells.b.a.d.zh var10;
      com.aspose.cells.b.a.b.za var11;
      switch(var7) {
      case -3:
         var7 = 6;
         var10 = new com.aspose.cells.b.a.d.zh();
         var11 = (com.aspose.cells.b.a.b.za)com.aspose.cells.b.a.b.za.a(var5);
         if (var6[4] == 0) {
            var11.a(96.0F, 96.0F);
         }

         var11.a(var10, ImageFormat.getPng());
         var11.d();
         if (var6[4] == 0) {
            byte[] var12 = var10.o();
            com.aspose.cells.a.d.zbm var13 = com.aspose.cells.a.d.zbn.r(var12);
            var8 = (int)(var13.f() * (double)var2 / 72.0D + 0.5D);
            var9 = (int)(var13.g() * (double)var3 / 72.0D + 0.5D);
         }

         var10.b(0L);
         com.aspose.cells.b.a.d.zh var15 = new com.aspose.cells.b.a.d.zh();
         com.aspose.cells.a.d.zfh var17 = new com.aspose.cells.a.d.zfh(var1, var15);
         var17.a((com.aspose.cells.b.a.d.zm)var10);
         var10.a();
         var1 = var15.o();
         var15.a();
         break;
      case -2:
      case -1:
      case 0:
      case 1:
      default:
         var7 = 6;
         var10 = new com.aspose.cells.b.a.d.zh();
         var11 = (com.aspose.cells.b.a.b.za)com.aspose.cells.b.a.b.za.a(var5);
         if (var6[4] == 0) {
            var11.a(96.0F, 96.0F);
         }

         var11.a(var10, ImageFormat.getPng());
         var11.d();
         var1 = var10.o();
         if (var6[4] == 0) {
            com.aspose.cells.a.d.zbm var16 = com.aspose.cells.a.d.zbn.r(var1);
            var8 = (int)(var16.f() * (double)var2 / 72.0D + 0.5D);
            var9 = (int)(var16.g() * (double)var3 / 72.0D + 0.5D);
         }

         var10.a();
         break;
      case 2:
      case 3:
      case 4:
         var4 = (int)(var5.h() - var5.i());
         var1 = new byte[var4];
         var5.a(var1, 0, var1.length);
         var1 = zcgc.a(var1);
         break;
      case 5:
      case 6:
         var1 = new byte[(int)var5.h()];
         var5.a(var1, 0, var1.length);
      }

      byte[] var14 = com.aspose.cells.a.c.zq.a(var1);
      this.b = new zux();
      this.b.c = var14;
      this.a = var7;
      this.b.a = var7;
      this.b.b = var7;
      this.c = new zcv(this, var1, var4);
      this.f = var6[3];
      this.e = var9;
      this.d = var8;
   }

   static int[] a(com.aspose.cells.b.a.d.zm var0, int var1, int var2) throws Exception {
      int[] var3 = new int[5];
      var3[0] = 1;
      Object var4 = null;

      byte[] var10;
      try {
         var10 = new byte[(int)var0.h()];
         var0.a(var10, 0, var10.length);
         int var5 = com.aspose.cells.a.d.zbn.a(var10);
         com.aspose.cells.a.d.zbm var6 = com.aspose.cells.a.d.zbn.a(var10, var5);
         switch(var5) {
         case 0:
            var3[0] = 1;
            break;
         case 1:
            var3[0] = 2;
            break;
         case 2:
            var3[0] = 3;
            break;
         case 3:
            var3[0] = 4;
            break;
         case 4:
            var3[0] = 5;
            break;
         case 5:
            var3[0] = 6;
            break;
         case 6:
            var3[0] = 254;
            break;
         case 7:
            var3[0] = 253;
            break;
         case 8:
            var3[0] = 1;
         }

         double var7 = Math.abs(var6.f());
         var3[1] = (int)(var7 * (double)var1 / 72.0D + 0.5D);
         var7 = Math.abs(var6.g());
         var3[2] = (int)(var7 * (double)var1 / 72.0D + 0.9D);
         var3[3] = (int)var6.d();
         var3[4] = var3[3] == 96 ? 0 : 1;
      } catch (Exception var9) {
         return var3;
      }

      if (var0.e()) {
         if (var3[0] == 3) {
            if (var10 != null) {
               if (com.aspose.cells.b.a.zc.a(var10, 0) == -1698247209) {
                  var0.a(22L, 0);
               } else {
                  var0.a(0L, 0);
               }
            } else {
               var0.a(22L, 0);
            }
         } else {
            var0.a(0L, 0);
         }
      }

      return var3;
   }

   static ImageFormat a(byte[] var0) throws Exception {
      com.aspose.cells.b.a.d.zh var1 = new com.aspose.cells.b.a.d.zh(var0);
      com.aspose.cells.b.a.b.zj var2 = com.aspose.cells.b.a.b.zj.a((com.aspose.cells.b.a.d.zm)var1);
      return var2.e();
   }

   static byte[] b(byte[] var0) {
      if (var0[0] == 66 && var0[1] == 77) {
         return var0;
      } else {
         try {
            int var1 = com.aspose.cells.b.a.zc.a(var0, 20);
            byte[] var2 = new byte[var0.length + 54];
            var2[0] = 66;
            var2[1] = 77;
            System.arraycopy(com.aspose.cells.b.a.zc.a(var2.length), 0, var2, 2, 4);
            var2[10] = 54;
            System.arraycopy(var0, 0, var2, 14, var0.length);
            return var2;
         } catch (Exception var3) {
            return var0;
         }
      }
   }

   void a(zcb var1) {
      this.b = new zux();
      this.b.a(var1.g());
      this.a = var1.a;
      this.c = new zcv(this);
      this.c.a(var1.c);
      this.e = var1.e;
      this.d = var1.d;
   }

   long c() {
      long var1 = this.c.b();
      return (var1 & 4294967295L) != 0L ? (var1 & 4294967295L) + 8L + 36L : 36L;
   }

   int d() {
      return this.f().e() == null ? 36 : this.c.f() + 8 + 36;
   }

   void c(byte[] var1) {
      byte var2 = 2;
      int var7 = var2 | (this.a & 255) << 4;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var7), 0, var1, 0, 2);
      var1[2] = 7;
      var1[3] = -16;
      long var3 = this.f().b();
      if ((var3 & 4294967295L) == 0L) {
         System.arraycopy(com.aspose.cells.b.a.zc.a((var3 & 4294967295L) + 36L), 0, var1, 4, 4);
      } else {
         System.arraycopy(com.aspose.cells.b.a.zc.a((var3 & 4294967295L) + 8L + 36L), 0, var1, 4, 4);
      }

      byte var5 = 8;
      var1[var5] = this.b.a;
      var1[var5 + 1] = this.b.b;
      int var8 = var5 + 2;
      System.arraycopy(this.b.c, 0, var1, var8, 16);
      var8 += 16;
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.b.d), 0, var1, var8, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a((var3 & 4294967295L) + 8L), 0, var1, var8 + 2, 4);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.b.e), 0, var1, var8 + 6, 4);
      var1[var8 + 14] = this.b.f;
      var1[var8 + 15] = 0;
      var8 += 18;
      if (this.f().e() != null) {
         var7 = this.f().d() << 4;
         System.arraycopy(com.aspose.cells.b.a.zc.a(var7), 0, var1, var8, 2);
         var7 = this.f().c();
         System.arraycopy(com.aspose.cells.b.a.zc.a(var7), 0, var1, var8 + 2, 2);
         System.arraycopy(com.aspose.cells.b.a.zc.a(var3), 0, var1, var8 + 4, 4);
         var8 += 8;
         if (this.c.a() != null) {
            System.arraycopy(this.c.a(), 0, var1, var8, this.c.a().length);
            var8 += this.c.a().length;
         }

         System.arraycopy(this.b.c, 0, var1, var8, 16);
         var8 += 16;
         if (this.f().g()) {
            System.arraycopy(com.aspose.cells.b.a.zc.a(this.f().a), 0, var1, var8, 4);
            var8 += 4;
            System.arraycopy(com.aspose.cells.b.a.zc.a((int)0), 0, var1, var8, 4);
            System.arraycopy(com.aspose.cells.b.a.zc.a((int)0), 0, var1, var8 + 4, 4);
            int var6 = this.k();
            if (this.n() == 3 && this.f != 96) {
               var6 = (int)((double)((float)(var6 * this.f) / 96.0F) + 0.5D);
            }

            System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, var1, var8 + 8, 4);
            var6 = this.l();
            if (this.n() == 3 && this.f != 96) {
               var6 = (int)((double)((float)(var6 * this.f) / 96.0F) + 0.5D);
            }

            System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, var1, var8 + 12, 4);
            var8 += 16;
            var6 = (int)((double)((float)this.k() / 96.0F * 914400.0F) + 0.5D);
            System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, var1, var8, 4);
            var6 = (int)((double)((float)this.l() / 96.0F * 914400.0F) + 0.5D);
            System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, var1, var8 + 4, 4);
            var8 += 8;
            var6 = this.f().e().length;
            System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, var1, var8, 4);
            var8 += 4;
            var1[var8] = this.f().b;
            var1[var8 + 1] = this.f().c;
            var8 += 2;
         } else {
            var1[var8] = this.f().d;
            ++var8;
         }

      }
   }

   byte[] e() {
      long var1 = this.f().b();
      byte[] var3 = new byte[(int)((var1 & 4294967295L) + 8L)];
      byte var4 = 0;
      int var5 = this.f().d() << 4;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var5), 0, var3, var4, 2);
      var5 = this.f().c();
      System.arraycopy(com.aspose.cells.b.a.zc.a(var5), 0, var3, var4 + 2, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(var1), 0, var3, var4 + 4, 4);
      int var7 = var4 + 8;
      if (this.c.a() != null) {
         System.arraycopy(this.c.a(), 0, var3, var7, this.c.a().length);
         var7 += this.c.a().length;
      }

      System.arraycopy(this.b.c, 0, var3, var7, 16);
      var7 += 16;
      if (this.f().g()) {
         System.arraycopy(com.aspose.cells.b.a.zc.a(this.f().a), 0, var3, var7, 4);
         var7 += 4;
         System.arraycopy(com.aspose.cells.b.a.zc.a((int)0), 0, var3, var7, 4);
         System.arraycopy(com.aspose.cells.b.a.zc.a((int)0), 0, var3, var7 + 4, 4);
         int var6 = this.k();
         if (this.n() == 3 && this.f != 96) {
            var6 = (int)((double)((float)(var6 * this.f) / 96.0F) + 0.5D);
         }

         System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, var3, var7 + 8, 4);
         var6 = this.l();
         if (this.n() == 3 && this.f != 96) {
            var6 = (int)((double)((float)(var6 * this.f) / 96.0F) + 0.5D);
         }

         System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, var3, var7 + 12, 4);
         var7 += 16;
         var6 = (int)((double)((float)this.k() / 96.0F * 914400.0F) + 0.5D);
         System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, var3, var7, 4);
         var6 = (int)((double)((float)this.l() / 96.0F * 914400.0F) + 0.5D);
         System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, var3, var7 + 4, 4);
         var7 += 8;
         var6 = this.f().e().length;
         System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, var3, var7, 4);
         var7 += 4;
         var3[var7] = this.f().b;
         var3[var7 + 1] = this.f().c;
         var7 += 2;
      } else {
         var3[var7] = this.f().d;
         ++var7;
      }

      if (this.f().e() != null) {
         System.arraycopy(this.f().e(), 0, var3, var7, this.f().e().length);
      }

      return var3;
   }

   void a(byte[] var1, int var2) {
      this.f = var2;
      this.b = new zux();
      this.c = new zcv(this);
      byte var3 = 0;
      zcv var4 = this.c;
      var4.a((short)((com.aspose.cells.b.a.zc.e(var1, var3) & '\uffff') >> 4));
      var4.a(com.aspose.cells.b.a.zc.e(var1, var3 + 2));
      switch(var4.d()) {
      case 534:
      case 535:
         this.a((byte)3);
         break;
      case 980:
      case 981:
         this.a((byte)2);
         break;
      case 1130:
      case 1131:
         this.a((byte)5);
         break;
      case 1346:
      case 1347:
         this.a((byte)6);
         break;
      case 1760:
      case 1761:
         this.a((byte)6);
         break;
      case 1960:
      case 1961:
         this.a((byte)6);
      }

      this.b.b = this.n();
      this.b.a = this.n();
      com.aspose.cells.b.a.zc.a(var1, var3 + 4);
      int var11 = var3 + 8;
      boolean var6 = false;
      switch(this.n()) {
      case 4:
         var6 = (var4.d() ^ 1346) == 1;
      case 5:
      default:
         break;
      case 6:
         var6 = (var4.d() ^ 1760) == 1;
         break;
      case 7:
         var6 = (var4.d() ^ 1960) == 1;
      }

      int var7;
      if (var4.g()) {
         var11 += 16;
         if (var6) {
            var4.a(new byte[16]);
            System.arraycopy(var1, var11, var4.a(), 0, 16);
            var11 += 16;
         }

         var4.a = com.aspose.cells.b.a.zc.a(var1, var11);
         var11 += 4;
         var7 = com.aspose.cells.b.a.zc.a(var1, var11 + 8) - com.aspose.cells.b.a.zc.a(var1, var11);
         var11 += 16;
         this.a((int)((double)(com.aspose.cells.b.a.zc.a(var1, var11) * var2 / 914400) + 0.5D));
         this.b((int)((double)(com.aspose.cells.b.a.zc.a(var1, var11 + 4) * var2 / 914400) + 0.5D));
         if (this.n() == 3 && this.k() != 0) {
            this.c(var7 * 96 / this.k());
         }

         var11 += 8;
         var11 += 4;
         var4.b = var1[var11];
         var4.c = var1[var11 + 1];
         var11 += 2;
      } else {
         if (var6) {
            var4.a(new byte[16]);
            System.arraycopy(var1, var11, var4.a(), 0, 16);
            var11 += 16;
         }

         var4.d = var1[var11 + 16];
         var11 += 17;
      }

      var7 = var1.length - var11;
      var4.b(new byte[var7]);
      System.arraycopy(var1, var11, var4.e(), 0, var7);
      byte[] var8 = com.aspose.cells.a.c.zq.a(var4.e());
      this.g().c = var8;
      if (!this.f().g()) {
         switch(this.n()) {
         case 7:
            this.a(com.aspose.cells.b.a.zc.a(var4.e(), 4));
            this.b(com.aspose.cells.b.a.zc.a(var4.e(), 8));
            break;
         default:
            try {
               int[] var9 = com.aspose.cells.a.c.zn.a(this.n() == -2, var4.e(), var2);
               this.a(var9[0]);
               this.b(var9[1]);
            } catch (Exception var10) {
               ;
            }
         }
      }

   }

   zcv f() {
      return this.c;
   }

   zux g() {
      return this.b;
   }

   byte[] h() {
      return this.b.c;
   }

   void i() {
      ++this.g().e;
   }

   void j() {
      ++this.g().e;
   }

   int k() {
      return this.d;
   }

   void a(int var1) {
      this.d = var1;
   }

   int l() {
      return this.e;
   }

   void b(int var1) {
      this.e = var1;
   }

   int m() {
      return this.f;
   }

   void c(int var1) {
      this.f = var1;
   }

   byte n() {
      return this.a;
   }

   void a(byte var1) {
      this.a = var1;
   }
}
